home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Corpus / IACorpus.h < prev    next >
Encoding:
Text File  |  1998-04-16  |  2.9 KB  |  95 lines  |  [TEXT/CWIE]

  1. // IACorpus.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5. #ifndef IACorpus_h
  6. #define IACorpus_h
  7.  
  8. #pragma import on
  9. #if PRAGMA_STRUCT_ALIGN
  10.     #pragma options align=power
  11. #endif
  12.  
  13. #include "IAStorable.h"
  14.  
  15. #pragma IA_BEGIN_EXPORTS
  16.  
  17. class IADoc : public IAOrderedStorable {
  18. public:
  19.     IA_INLINE            ~IADoc() IA_INLINE_DEF()        // no-op dtor def
  20.     // returns the name of a document -- for test applications
  21.     // note: returned array is allocated by IAMallocArray() and should be freed by IAFreeArray().
  22.     virtual byte*        GetName(uint32 *length) const;
  23. };
  24.  
  25. class IADocText : public IAObject {
  26. public:
  27.     IA_INLINE            ~IADocText() IA_INLINE_DEF()    // no-op dtor def
  28.     // Extracts successive segments of the text of the document.
  29.     // Returns number of bytes written into buffer.
  30.     // Returns zero at end of document.
  31.     virtual uint32        GetNextBuffer(byte* buffer, uint32 bufferLen) = 0;
  32.     virtual IADocText*    DeepCopy() const = 0;
  33. };
  34.  
  35. class IADocIterator : public IAObject {
  36. public:
  37.     IA_INLINE            ~IADocIterator() IA_INLINE_DEF()// no-op dtor def
  38.     // Advances the iterator to the next document in a set and returns it.
  39.     // Enumeration is ordered, i.e., each document is LessThan() the next.
  40.     // Returns NULL at the end of the set.
  41.     // Note: returns a new copy of the document.  Clients must delete.
  42.     virtual IADoc*    GetNextDoc() = 0;
  43. };
  44.  
  45. // Thrown if iterator returns items that are not LessThan() next.
  46. IAExceptionCode                CorpusIteratorOutOfOrder = 'VCIO';
  47.  
  48. class IACorpus : public IAObject {
  49. public:
  50.                         IACorpus(uint32 type) : corpusType(type) {}
  51.     IA_INLINE    virtual        ~IACorpus() IA_INLINE_DEF()        // no-op dtor def
  52.  
  53.     // Initializes persistent state.
  54.     void                Initialize(IAStorage* storage, IABlockID block);
  55.     // Reads persistent state, including that of all analyses used.
  56.     void                Open(IAStorage* storage, IABlockID block);
  57.     // Flushes any changes to persistent state, including that of all analyses used.
  58.     void                Update(IAStorage* storage, IABlockID block);
  59.  
  60.     // returns a prototype document, for bootstrapping sets of documents
  61.     virtual IADoc*        GetProtoDoc() = 0;
  62.  
  63.     // accesses the text of a document
  64.     virtual IADocText*    GetDocText(const IADoc* doc) = 0;
  65.     
  66.     // Determines set of documents to be indexed. 
  67.     virtual IADocIterator* GetDocIterator();
  68.  
  69.     const uint32 GetCorpusType() const {return corpusType;}
  70.     
  71. protected:
  72.     // Initialize() is implemented by subclasses with the following two methods:
  73.     virtual IABlockSize    InitialSize();
  74.     virtual void        Initializing(IAOutputBlock* output);
  75.     // Open() is implemented by subclasses with the following:
  76.     virtual void        Opening(IAInputBlock* input);
  77.     // Update() is implemented by subclasses with the following two methods:
  78.     virtual IABlockSize    UpdateSize();
  79.     virtual void        Updating(IAOutputBlock* output);
  80. private:
  81.     const uint32        corpusType;
  82.  
  83. };
  84.  
  85. IAExceptionCode                InvalidDocument = 'VCID';
  86.  
  87. #pragma IA_END_EXPORTS
  88.  
  89. #if PRAGMA_STRUCT_ALIGN
  90.     #pragma options align=reset
  91. #endif
  92.  
  93. #pragma import reset
  94. #endif
  95.